<?php

namespace App\ZhCN;

if (!defined('IN_PX'))
    exit;

use App\Service;
use App\Repository;
use Phoenix\Log\Log4p as logger;

/**
 * 首页
 */
class Center {

    private function __Controller() {}

    private function __Value($__PACKAGE__, $__ROOT__, $__RM__, $setting, $cfg, $__LANGUAGE_ID__) {}

    protected function __Inject($session, Service\Archives $servArc, Repository\Archives $repoArc, Repository\Member $repoMem, Repository\Collection $repoColl) {}

    public function center($__Route = array('/member/center'))
    {
        if ($this->servArc->chkCategoryDataView()) {
            $_model['aryCategoryDataView'] = $this->servArc->aryCategoryDataView;
            if ($this->__LANGUAGE_ID__ == 1) {
                $_model['pageSeoTitle'] = 'Bondent Group';
            }

            $_model['status'] = 'center';
            $userInfo = $this->session->member;
            $_model['member'] = $this->repoMem->findMember($userInfo['member_id'], 1);
            //首页底部链接
            return array(
                'model' => $_model,
                'view' => 'member/index'
            );
        }
    }

    public function change($__Route = array('/member/change'))
    {
        if ($this->servArc->chkCategoryDataView()) {
            $_model['aryCategoryDataView'] = $this->servArc->aryCategoryDataView;
            if ($this->__LANGUAGE_ID__ == 1) {
                $_model['pageSeoTitle'] = 'Bondent Group';
            }

            $_model['status'] = 'center';
            //首页底部链接
            return array(
                'model' => $_model,
                'view' => 'member/change'
            );
        }
    }


    public function collection($__Route = array('/member/collection/{page}'))
    {
        if ($this->servArc->chkCategoryDataView()) {
            $_model['aryCategoryDataView'] = $this->servArc->aryCategoryDataView;
            $_model['aliasId'] = $this->repoArc->aliasId($this->__LANGUAGE_ID__, 'member/collection');
            if ($this->__LANGUAGE_ID__ == 1) {
                $_model['pageSeoTitle'] = 'Bondent Group';
            }
            $userInfo = $this->session->member;
            if (!isset($this->page)) {
                $this->page = 1;
            }
            $_model['currentPage'] = $this->page;
            $_model['currentPageSize'] = 1;

            $_model['currentCategoryTotal'] = $this->repoColl->findAllCount($userInfo['member_id'], $this->__LANGUAGE_ID__);

            $_model['currentListRs'] = $this->repoColl->findAll($userInfo['member_id'], $this->__LANGUAGE_ID__,
                $_model['currentPageSize'] * ($_model['currentPage'] - 1),
                $_model['currentPageSize']);

            $_model['status'] = 'collection';
            //首页底部链接
            return array(
                'model' => $_model,
                'view' => 'member/collection'
            );
        }
    }

    public function video($__Route = array('/member/video'))
    {
        if ($this->servArc->chkCategoryDataView()) {
            $_model['aryCategoryDataView'] = $this->servArc->aryCategoryDataView;
            $_model['aliasId'] = 'member/video';
            if ($this->__LANGUAGE_ID__ == 1) {
                $_model['pageSeoTitle'] = 'Bondent Group';
            }

            $userInfo = $this->session->member;
            if (!isset($this->page)) {
                $this->page = 1;
            }
            $_model['currentPage'] = $this->page;
            $_model['currentPageSize'] = 5;

            $_model['currentCategoryTotal'] = $this->repoColl->findAllCount($userInfo['member_id'], $this->__LANGUAGE_ID__);

            $_model['currentListRs'] = $this->repoColl->findAll($userInfo['member_id'], $this->__LANGUAGE_ID__,
                $_model['currentPageSize'] * ($_model['currentPage'] - 1),
                $_model['currentPageSize']);

            $_model['status'] = 'video';
            //首页底部链接
            return array(
                'model' => $_model,
                'view' => 'member/video'
            );
        }
    }
}
